package cn.jdy.plugins.service;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.SQLQuery;
import org.springframework.stereotype.Service;

import cn.jdy.framework.db.hibernate.BaseDao;
import cn.jdy.plugins.entity.RemoteAssociations;

/**
 * @author wuzhiliang
 * @title : 文章操作实现
 */
@Service
public class RemoteAssociationsService extends BaseDao<RemoteAssociations> {

//	@Autowired
//	private ConfService confService;
	public Map<String, Object> getnums(String name) {
		Map<String, Object> map = new HashMap<String, Object>();
	   // String sql = "SELECT COUNT(id) FROM remoteassociations WHERE "+name+" IS NOT NULL";
		String sql = "SELECT COUNT(id) FROM news WHERE isarticle='1' and username='"+name+"' ";
	    SQLQuery query = super.em().createSQLQuery(sql.toString());
	    map.put("dataList", query.list());
	    return map;
	  }
	
	/**
	   * 查询地方
	   * @param name
	   * @return
	   */
	  public long rautils(String name){
		  Map<String, Object> map=this.getnums(name);
		  List list=(List)map.get("dataList");//cnt
		  int imax=list.size();
		  for(int i=0;i<imax;i++){
			  Long cnt = ((BigInteger) list.get(i)).longValue();
			  return cnt;
		  }
		  return 0;
	  }
	  

}
